
#include "app_config.h"
#include "../../middle/serve/memory_mange/memory_mang_conf.h"
#if (TEST_MEMORY_TEST_HEAP5 && FREE_RTOS_HEAP_)

#include <stdio.h>
#include <stdint.h>
#include "../../middle/serve/memory_mange/FreeRTOS_heap5.h"
#include "c_mem.h"
#include "macro_overload.h"


/* 内部RAM 的地址和大小 */
#define RAM1_HEAP_SIZE   1024
uint8_t heap_ram1[RAM1_HEAP_SIZE]={0};

#define RAM2_HEAP_SIZE   1024
uint8_t heap_ram2[RAM1_HEAP_SIZE]={0};

/* 外挂RAM 的地址和大小 */
#define EXT_RAM3_HEAP_SIZE   512
#define EXT_HEAP_RAM3_START   ( (uint8_t * ) 0X00020000)

/**
 * @brief 堆空间分配
 * 
 */
const pt_heap_region_t HeapRegions[] =
{
    { heap_ram1, RAM1_HEAP_SIZE },
    { heap_ram2, RAM2_HEAP_SIZE },
#ifndef __GNUC__
    { EXT_HEAP_RAM3_START, EXT_RAM3_HEAP_SIZE },
#endif
    { NULL, 0 } /* Marks the end of the array. */
};



void test()
{
    /* init region */
    pt_heap_region(HeapRegions);

    uint8_t *ptr ;

    DEBUG_INFO_PRINT("----TEST memory mange heap5:\n ");
    
    ptr = (uint8_t*)pt_malloc(8);

    c_memset(ptr, 5,8);
    printf(" start addr %p \n data:",(int)ptr);

    foreach(uint8_t, ptr,item)
    {
        printf("%d ,",*item);
    }
    printf("\n");

    pt_free(ptr);

    ptr = (uint8_t*)pt_malloc(254);
    c_memset(ptr, 5,8);
    printf(" start addr %p \n ",(int)ptr);

    ptr = (uint8_t*)pt_malloc(23);
    c_memset(ptr, 5,8);
    printf(" start addr %p \n ",(int)ptr);


     ptr = (uint8_t*)pt_malloc(16);
    c_memset(ptr, 5,8);
    printf(" start addr %p \n ",(int)ptr);
   
}
EXPORT_Lv6_APP_SINGLE(test,NULL);

#endif